import * as actionTypes from "./actionTypes";
import { fromJS } from "immutable"; //把数据转为immutable对象，使用这个使用更要使用gget方法，使用set方法去变更state内容

const defaultState = fromJS({
  type: "codeLogin",//codeLogin：验证码，psdLogin：密码
  isLogin:   false,
  userInfor: {}
});
// 导出一个纯函数
export default (state = defaultState, action) => {
  switch (action.type) {
    case actionTypes.QuitHandle:
    
      return state.set("isLogin", false).set("userInfor", fromJS({}));
    case actionTypes.ChangeUser:
      return state.set("userInfor", fromJS(action.data));
    case actionTypes.ChangeType:
      return state.set("type", action.data);
    case actionTypes.LoginHandle:
      return state.set("isLogin", action.data);
    default:
      break;
  }
  return state;
};
